﻿
@page "/_Admin/FrameworkUser/BatchEdit"
@using SelfService.ViewModel._Admin.FrameworkUserVMs
@using System.ComponentModel.DataAnnotations
@inherits BasePage

<ValidateForm @ref="vform" Model="@Model" OnValidSubmit="@Submit">
  <div style="margin-bottom:10px;"> @WtmBlazor.Localizer["Sys.BatchEditConfirm"]</div>
  <Row ItemsPerRow="ItemsPerRow.Two" RowType="RowType.Normal">
    <BootstrapInput @bind-Value="@Model.LinkedVM.Email"/>
    <Select @bind-Value="@Model.LinkedVM.Gender" Id="g2d95465397a84c6dba78754aee75051a"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.CellPhone"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.HomePhone"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.Address"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.ZipCode"/>
    <MultiSelect @bind-Value="@Model.LinkedVM.SelectedFrameworkRoleFrameworkUser_MT_WtmsIDs" Items="AllFrameworkRoleFrameworkUser_MT_Wtms" Id="g46c7505e0cb5494aa62120acbc7d683c"/>
    <MultiSelect @bind-Value="@Model.LinkedVM.SelectedFrameworkGroupFrameworkUser_MT_WtmsIDs" Items="AllFrameworkGroupFrameworkUser_MT_Wtms" Id="gb444a315771d4a79ae02d31df972a8e1"/>
  </Row>

  <div class="modal-footer table-modal-footer">
    <Button ButtonType="ButtonType.Submit" IsAsync="true" Text="@WtmBlazor.Localizer["Sys.Submit"]"/>
    <Button OnClick="OnClose" Text="@WtmBlazor.Localizer["Sys.Close"]"/>
  </div>

</ValidateForm>



@code {
    [Parameter]
    public string id { get; set; }
    [Parameter]
    public string[] ids { get; set; }
    private FrameworkUserBatchVM Model = new FrameworkUserBatchVM();
    private ValidateForm vform { get; set; }
    
    private async Task Submit(EditContext context)
    {
        Model.Ids = ids;
        await PostsForm(vform, "/api/_Admin/FrameworkUser/BatchEdit", (s) => WtmBlazor.Localizer["Sys.BatchEditSuccess", s], method: HttpMethodEnum.POST);
    }
            

    public void OnClose()
    {
        CloseDialog();
    }
    
    private List<SelectedItem> AllFrameworkRoleFrameworkUser_MT_Wtms = new List<SelectedItem>();
    private List<SelectedItem> AllFrameworkGroupFrameworkUser_MT_Wtms = new List<SelectedItem>();
    protected override async Task OnInitializedAsync()
    {
        
        
        AllFrameworkRoleFrameworkUser_MT_Wtms = await WtmBlazor.Api.CallItemsApi("/api/_Admin/FrameworkUser/GetFrameworkRoles");
        AllFrameworkRoleFrameworkUser_MT_Wtms.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllFrameworkGroupFrameworkUser_MT_Wtms = await WtmBlazor.Api.CallItemsApi("/api/_Admin/FrameworkUser/GetFrameworkGroups");
        AllFrameworkGroupFrameworkUser_MT_Wtms.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });

        await base.OnInitializedAsync();
    }
}
